package generator

import "beergo/plugins/maker"

func init() {
	AdminMenu()
	AdminGroup()
	AdminUser()
}
func AdminMenu(){
	c:= maker.CreateTable("AdminMenu","后台菜单","admin")
	c.AddText("name","名称").SetLength(32).SetNullable(true)//权限名称
	c.AddText("sort","排序").SetLength(10).SetNullable(true)//文本形式的排序
	c.AddText("path","标识链").SetLength(255).SetNullable(true)//路径
	c.AddText("url","链接").SetLength(255).SetNullable(true)
	c.AddText("icon","图标").SetLength(255).SetNullable(true)
	c.AddManyToOne("parent","父级","AdminMenu").SetNullable(true)
	c.AddOneToMany("children","子集","AdminMenu").SetNullable(true)
	c.AddManyToMany("groups","角色","AdminGroup").SetNullable(true).SetIsControl(false)
	c.Generate()
}
func AdminGroup(){
	c:= maker.CreateTable("AdminGroup","管理分组","admin")
	c.AddText("name","名称").SetLength(32).SetNullable(true)
	c.AddManyToMany("menus","角色","AdminMenu").SetNullable(true).SetIsControl(true)
	c.Generate()
}
func AdminUser(){
	c:= maker.CreateTable("AdminUser","后台管理员","admin")
	c.AddText("name","名称").SetLength(32).SetNullable(true)
	c.AddText("account","手机号").SetLength(32).SetNullable(true)
	c.AddText("password","密码").SetLength(32).SetNullable(true)
	c.AddText("token","Token").SetLength(255).SetNullable(true)
	c.AddText("salt","Salt").SetLength(32).SetNullable(true)
	c.AddInt("uid","系统用户Id").SetNullable(true)
	c.AddManyToMany("groups","角色","AdminGroup").SetNullable(false).SetIsControl(true)
	c.Generate()
}
